// JavaScript Document
$(function () {
	initDetail();	
});
//初始化
function initDetail(){
	getInfo(getQueryString("id"));
}
//获取详情
function getInfo(id){
	var str = 'orderUuid='+encodeURIComponent(id);
	getOData(str,"coreCartOrder/views",{fn:function(oData){
		if(oData.code == 1) {
			$(".crporUuid").text(oData.data.crporUuid || "");
			$(".crporUserName").text(oData.data.crporUserName || "");
			$(".crporCdate").text(oData.data.crporCdate || "");
			$(".crporUdate").text(oData.data.crporUdate || "");
			var crporStatusCH='交易成功';
			var crporStatus=oData.data.crporStatus;
			if(crporStatus==2){//1支付中2支付成功3支付失败4已发货5交易成功
				crporStatusCH='支付成功';
			}else if(crporStatus==3){
				crporStatusCH='支付失败';
			}else if(crporStatus==4){
				crporStatusCH='已发货';
			}else if(crporStatus==5){
				crporStatusCH='交易成功';
			}
			$(".crporStatus").text(crporStatusCH || "");
			$(".crporName").text(oData.data.crporName || "");
			$(".crporTel").text(oData.data.crporTel || "");
			$(".crporMail").text(oData.data.crporMail || "");
			$(".crporCity").text(oData.data.crporCity || "");
			$(".crporAddress").text(oData.data.crporAddress || "");
			$(".crporNumber").text(oData.data.crporNumber || "");
			$(".crporPrice").text(oData.data.crporPrice || "");
			$(".crporTotal").text(oData.data.crporTotal || "");
			$(".crporSjFee").text(oData.data.crporSjFee || "");
			$(".crporSyScore").text(oData.data.crporSyScore || "");
			$(".crporDkFee").text(oData.data.crporDkFee || "");
			$(".crporRemarks").text(oData.data.crporRemarks || "");
			
			//订单商品信息
			showList(oData.data.crporUuid);
		} else {
			alert(data.errMsg);
		}
	}});
}

function showList(crporUuid){
	var aData = [
	     {name:"商品名称",percent:"20"},
	     {name:"单价",percent:"10"},
	     {name:"数量",percent:"10"},
	     {name:"可获得积分",percent:"10"}];
	setTableHead(aData);
	var str = 'orderUuid='+encodeURIComponent(crporUuid);
	getOData(str,"coreCartOrder/find/by/cndDetail",{fn:function(oData){
			var strhtml_list = "";   
			var arrData = oData.data;
			var ln = arrData.length;  
			for(var i=0;i<ln;i++){ 
				strhtml_list += '<tr class="trHighLight">'
					+'<td>'+(arrData[i].criglGoodsName || "")+'</td>'
					+'<td>'+(arrData[i].criglGoodsPrice || "")+'</td>'
					+'<td>'+(arrData[i].criglGoodsAmount || "")+'</td>'
				 	+'<td>'+(arrData[i].criglGoodsScore || "")+'</td>'
		            +'</tr>';
			}
			$(".tb-body").html(strhtml_list);
		}}
	);
}
